.PHONY: all clean build

# instead of exporting NUL, DLL_OR_SO etc move them into common.mk (target.mk)
# and include from here

NUL ?= /dev/null
DLL_OR_SO ?= so

SRC = $(wildcard *.erl)
BEAMS = $(patsubst %.erl, build/%.beam, $(SRC))

all: $(BEAMS) build/types.$(DLL_OR_SO)

build/%.beam: %.erl
	@mkdir build 2> $(NUL) | cat
	erlc -o build $<

build/types.dll: types.c
	@mkdir build 2> $(NUL) | cat
	$(CC) -LD -Fobuild/ -Febuild/ /Tctypes.c

build/types.so: types.c
	mkdir -p build
	gcc -shared -o $@ $<

clean:
	rm -rf build
